package com.tencent.wxcloudrun.config;


import com.tencent.wxcloudrun.util.CheckSignatureUtil;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
import java.io.PrintWriter;

//@WebFilter
//public class MyFilter implements Filter {
//
//    @Override
//    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain) throws IOException, ServletException {
//        //获取微信服务器传来的相关参数
//        String signature = req.getParameter("signature");
//        String timestamp = req.getParameter("timestamp");
//        String nonce = req.getParameter("nonce");
//        String echostr = req.getParameter("echostr");
//        PrintWriter out = resp.getWriter();
//        //调用比对signature的方法，实现对token和传入的参数进行hash算法后的结果比对
//        System.out.println("" + signature + "--" + timestamp + "--" + nonce + "--" + echostr);
//        if (CheckSignatureUtil.checkSignature(signature, timestamp, nonce)) {
//            out.print(echostr);
//        }
//        filterChain.doFilter(req,resp);
//    }
//}
